<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" import="java.util.List,com.telecom.cms.dto.PreviewSet"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
	prefix="logic"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
 List cimpagelist=(List)request.getAttribute("cimpagelist");
 int step=Integer.parseInt(request.getAttribute("step").toString()),curstep=0;
%>
<html>
	<head>
		<title>JSP for SysTeamForm form</title>
		<LINK href="css/default.css" rel=stylesheet>
		<LINK href="css/button.css" rel=stylesheet>
		<script src="js/prototype.js"></script>
		<script language="javascript" type="text/javascript">
		function opchange(o){
		//alert(o);
		document.previewForm.method.value=o;
		//alert(document.previewForm.method.value);
		document.previewForm.submit();
		}
		
		function showimg(){
		  alert('aa');
		}
		
		function geninfo()
    {
    $("info").innerHTML="";
    $("imgsubmit").style.display="none";
    $("info").style.display="block";
    $("execing").style.display="block";
    $("execing").style.position="absolute";
    $("execing").style.left=200;
    $("execing").style.top=200;
    $("execing").style.background="#FFCC99";
    $("method").value="exec";
	var url = '/tcms/preview.do';
	var pars = Form.serialize('previewForm');
	//alert(pars);
	var myAjax = new Ajax.Request(
	url,
	{
	method: 'get',
	parameters: pars,
	onComplete: showResponse
	});
}
function showResponse(originalRequest)
{
$("execing").style.display="none";
$("info").innerHTML=originalRequest.responseText;
$("info").style.background="#FFCC99";
$("info").style.display="block";
$("info").style.position="absolute";
$("info").style.left=200;
$("info").style.top=20;
}
		</script>
	</head>
	<body>

		<html:form action="/preview">

			<div id="id0">
				<table width="700" cellspacing="0" cellpadding="0" border="0" align="center">
					<tbody>
						<tr>
							<td width="3" height="31">
								<img height="31" src="./images/table_01.gif" width="3" />
							</td>
							<td colspan="2" background="./images/table_02.gif" height="31">
								<table cellspacing="0" cellpadding="0"   align="left"
									border="0">
									<tbody>
										<tr>
											<td   background="./images/title_1_bg.gif">
												<img height="31" src="./images/title_1.gif" width="51" />
											</td>
											<td   background="./images/title_1_bg.gif">
												<span class="color_b_666">高危锁定</span>
											</td>
										</tr>
									</tbody>
								</table>
							</td>
							<td width="3">
								<img height="31" src="./images/table_03.gif" width="3" />
							</td>
						</tr>
						<tr>
							<td width="3" background="./images/table_04.gif" width="3"
							align="right">
							<img height="100%" src="./images/table_04.gif" width="3" />
					    	</td>
							<td colspan="2"  height="31">
								<table cellspacing="0" cellpadding="0"   align="left" width="700"
									border="1">
									<tbody>
										
								
							
							<logic:present name="cimpagelist">
							<logic:iterate name="cimpagelist" id="i">
								<%if(curstep++<step){ %>
								<tr> 
								<td >
 								<b><img src="images/li2.gif"/><bean:write name="i" property="step_name" /></b><br />
								&nbsp;&nbsp;&nbsp;&nbsp;<bean:write name="i" property="step_comment" />
								</td>
								<td>
								<logic:equal name="i" property="step_type"  value="select">
								<select id="<bean:write name="i" property="step_id" />" name="<bean:write name="i" property="step_id" />">
								     <%String showdata[]=((PreviewSet)i).getStep_showdata().split(";");
								       for(int j=0;j<showdata.length;j++)
								       {
								           String options[]=showdata[j].split(",");
								           if(options.length>=2)
								             out.print("<option value='"+options[0]+"'>"+options[1]+"</option>");
								           else
								             out.print("<option value='"+options[0]+"'>"+options[0]+"</option>");
								      }
								       %>
								</select>
								</logic:equal>
								
								<logic:equal name="i" property="step_type"  value="input">
								<input type="text" name="<bean:write name="i" property="step_id" />" id="<bean:write name="i" property="step_id" />" value="<bean:write name="i" property="step_default" />" />
								</logic:equal>
								<br />
								<bean:write name="i" property="step_append" />
								</td>
								</tr>
								<logic:notEqual name="i" property="step_next"  value="">
								<tr><th></th></tr>
								</logic:notEqual>
								<%} %>
							</logic:iterate>
							<tr><td align="center" colspan="2">
							    <html:hidden property="step" value="<%=((PreviewSet)cimpagelist.get(step-1)).getStep_next() %>" />
							    							    <html:hidden property="method" value="step" />
								<html:hidden property="previewid" value="${previewid}" />
							    <%
							    System.out.println(""+cimpagelist.size()+step);
							    if(cimpagelist.size()==step){ %>
								  <img src='images/button_preview.jpg' id="imgsubmit" width="63" height="21" onclick="geninfo()" />
								<% }else{%>
								  <img src='images/button_next.jpg' id="imgsubmit" width="63" height="21" onclick="opchange('step')" />
								<%} %>
								</td>

							</tr>
							</logic:present>
						</tbody>
						</table>
					    </td>
						<td background="./images/table_05.gif" width="3" align="left">
							<img height="100%" src="./images/table_05.gif" width="3">
						</td>
					</tr>
					<tr>
						<td height=3 valign="top">
							<img height="12px" src="./images/table_06.gif" width="3px">
						</td>
						<td height=3 colspan="2" valign="top">
							<img height="3px" src="./images/table_07.gif" width="100%">
						</td>
						<td height=3 valign="top">
							<img height="12px" src="./images/table_08.gif" width="3px">
						</td>
					</tr>
				<tbody>
			</table>
			</div>
			<br />
			<div id="info" align="center" >
			</div>
			<div id="execing" align="center" style="display:none;position:absolute;left=200;top=100;">
			  <table width='200' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#FF9900' align='center'>
			  <tr></tr><img src="images/execing.gif" /> 正在查询数据，请稍候....
			  </table>
			</div>
			

		</html:form>
        <script language="javascript" type="text/javascript">		
              $("execing").style.display="none";
		</script>
	</body>
</html>

